


***********************************************
****** The Impact of Soft-Skills Training *****
******    for Entrepreneurs in Jamaica    *****
***********************************************


* This is the code for the replication of the paper "The Impact of Soft-Skills Training for Entrepreneurs in Jamaica".
* This do-file analyzes all the data, producing tables and figures.

* Please read the related README file to understand how to run this do-file.



clear all
cap log close
set more off
set varabbrev off




*******************
*** Directories ***
*******************

* Set global macros with directories
global directory "## INSERT HERE YOUR MAIN DIRECTORY ##"
global data_raw "Data/Raw data"
global data_int "Data/Intermediate and auxiliary data"
global data_fin "Data/Final data"
global results_tab "Results/Tables"
global results_fig "Results/Figures"
global codes "Codes"

* Change current directory
cd "$directory"




**********************
*** External codes ***
**********************


*** Load codes for balance tables ***

* Install balancetable from SSC
cap which balancetable
if _rc ssc install balancetable

* Load custom balance table code
do "$codes/balancetable_custom.ado"


*** Load codes for Multiple Hypothesis Testing ***

* Install mhtexp from SSC
cap which mhtexp
if _rc ssc install mhtexp

* Load mata library
mata: mata mlib index

* Check Stata version for multiple hypothesis testing
if int(c(version))<15 {
	dis as error "Your Stata version does not allow the computation of MHT p-values"
	qui exit
}




************
*** Data ***
************


*** Load merged data ***

* Load data prepared for analysis
use "$data_fin/Jamaica_data_final", clear


*** Define macros ***

* Define global macros with list of covariates
global all_covariates female has_employees edu_sec_more course_kingston course_clarendon course_stthomas age black married num_children internet_access parents_entrep ///
	save_bank loan_bank loan_notaccess set_goal business_wchange satisfied_job reservation_wage personal_initiative perseverance locus_control risk_willing expenditures ///
	pre_course active_business busage_l1 formal_accounts informal_accounts register_bus sales_lastm profits_lastm innovation business_practices_index barriers_couple
global all_covariates_m
global all_covariates_d
foreach var of varlist $all_covariates {
	global all_covariates_m "$all_covariates_m m_`var'"
	global all_covariates_d "$all_covariates_d d_`var'"
}

* Define global macros with list of for the joint test
global list_test age black married num_children internet_access parents_entrep save_bank loan_bank loan_notaccess set_goal business_wchange satisfied_job ///
	reservation_wage personal_initiative perseverance locus_control risk_willing expenditures pre_course active_business busage_l1 formal_accounts ///
	informal_accounts register_bus sales_lastm profits_lastm innovation business_practices_index barriers_couple
global list_test_m
global list_test_d
foreach var of varlist $list_test {
	global list_test_m "$list_test_m m_`var'"
	global list_test_d "$list_test_d d_`var'"
}

* Define global macros with list of control variables to include in all regressions
global controls married perseverance risk_willing formal_accounts
global controls_md
foreach var of varlist $controls {
	global controls_md "$controls_md m_`var' d_`var'"
}




*******************
*** Main tables ***
*******************


*** Table 1: Baseline Balance ***

* Perform orthogonality test (to be added to the table)
qui reg t1 $list_test_m $list_test_d i.strata if t2==0, robust
qui testparm $list_test_m
local orth1pval=strtrim("`: dis %3.2f r(p)'")
qui reg t2 $list_test_m $list_test_d i.strata if t1==0, robust
qui testparm $list_test_m
local orth2pval=strtrim("`: dis %3.2f r(p)'")

* Build balance table
format $all_covariates %9.2fc
format reservation_wage expenditures sales_lastm profits_lastm %9.0fc
balancetable_custom $all_covariates using "$results_tab/balance_fullsample.tex", replace robust nostars displayformat ///
	addpanels(female "Panel A. Stratification variables" age "Panel B. Owner characteristics" active_business "Panel C. Firm characteristics") ///
	prefoot("\addlinespace \multicolumn{10}{l}{\textbf{Panel D. Aggregate orthogonality test for panels B–C}}\\" ///
	"P-value &&&&&&& `orth1pval' & `orth2pval' &\\")




*** Table 2: Course Evaluations: satisfaction and knowledge test ***

* Compute summary statistics
eststo clear
_eststo t1: estpost summ satisf_index likely_skills likely_recom wtp_jmd knwl_pi knwl_bp_1 knwl_bp_2 knwl_ps_1 knwl_ps_2 if t1==1
_eststo t2: estpost summ satisf_index likely_skills likely_recom wtp_jmd knwl_pi knwl_bp_1 knwl_bp_2 knwl_ps_1 knwl_ps_2 if t2==1

* Store in matrices the p-value of the difference
tempname pval_mat
foreach var of varlist satisf_index likely_skills likely_recom wtp_jmd knwl_pi knwl_bp_1 knwl_bp_2 knwl_ps_1 knwl_ps_2 {
	reg `var' t1 if treatment!=0, robust
	test t1
	mat `pval_mat'=nullmat(`pval_mat'),r(p)
	local names_list "`names_list' `var'"
}
mat colnames `pval_mat' = `names_list'
_eststo diff: estpost summ satisf_index likely_skills likely_recom wtp_jmd knwl_pi knwl_bp_1 knwl_bp_2 knwl_ps_1 knwl_ps_2
estadd mat pval=`pval_mat'
estadd scalar N=-999 , replace			// without this trick, esttab would report the sample size from estpost summ (in the last column)
cap mat drop `pval_mat'

* Export summary stats table on course satisfaction and knowledge test
esttab _all using "$results_tab/summstats_course_assess.tex", replace ///
	cell((mean(label(Mean) pattern(1 1 0) fmt(2 2 2 %9.0fc 2)) sd(label(SD) pattern(1 1 0)) pval(label(P-value) pattern(0 0 1) fmt(3)))) ///
	star(* 0.10 ** 0.05 *** 0.01) label booktabs nomtitles nonumbers ///
	mgroups("\makecell{Soft-skills \\ training (T1)}" "\makecell{Combined \\ training (T2)}" "T1=T2", ///
		pattern(1 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) begin("&(1)&(2)&(3)&(4)&(5)\\")) ///
	varlabels(, blist(satisf_index "\multicolumn{6}{l}{\textbf{Panel A. Course satisfaction (1-7)}}\\" ///
		knwl_pi "\addlinespace \multicolumn{6}{l}{\textbf{Panel B. Knowledge test}}\\")) ///
	substitute("-999" "" "_" "\_" "$" "\$")




*** Table 3: Impacts on Main Outcomes by Survey Wave ***

* Compute regressions and store results for main outcomes
eststo clear
foreach var in has_business pos_profits_lastm sales_profits_index {
	forvalues i=1/2 {
		_eststo fu`i'_`var': reg fu`i'_`var' t1 t2 m_`var' d_`var' $controls_md i.strata i.fu`i'_month_interview, robust
		test t1=t2
		estadd scalar test_equality=r(p)
		summ fu`i'_`var' if treatment==0
		estadd scalar control_mean=r(mean)
	}
}

* Export regression results for survival, positive profits and sales and profits index
esttab *has_business *pos_profits_lastm *sales_profits_index using "$results_tab/bywave_main_outcomes_reduced.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2) nocon label booktabs nomtitles collabels(none) nonumbers nonotes ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mgroups("Firm survival" "Positive profits" "Sales and profits index", pattern(1 0 1 0 1 0) span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span}) begin("&(1)&(2)&(3)&(4)&(5)&(6)\\")) ///
	posthead("&\makecell{3-month \\ follow-up}&\makecell{12-month \\ follow-up}" ///
		"&\makecell{3-month \\ follow-up}&\makecell{12-month \\ follow-up}" ///
		"&\makecell{3-month \\ follow-up}&\makecell{12-month \\ follow-up}\\" "\midrule") ///
	substitute("@" "" "-0.00" "0.00" "_" "\_" "$" "\$")




*** Table 4: Mechanisms (3-month follow-up) ***

* Compute regression results for mechanisms in fu1
eststo clear
foreach var in business_practices_index personal_initiative_index inputs_index innovation loan_requested {
	_eststo `var': reg fu1_`var' t1 t2 m_`var' d_`var' $controls_md i.strata i.fu1_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu1_`var' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Add corrections for multiple hypothesis testing
tempname pval_mat
if int(c(version))>=15 {
	mhtexp fu1_business_practices_index fu1_personal_initiative_index fu1_inputs_index fu1_innovation fu1_loan_requested, treatment(treatment)
	forvalues i=1/5 {
		local est: word `i' of business_practices_index personal_initiative_index inputs_index innovation loan_requested
		local t1_pos=`i'*2-1
		local t2_pos=`i'*2
		mat `pval_mat'=J(1,2,.)
		mat colnames `pval_mat' = t1 t2
		mat `pval_mat'[1,1]=results[`t1_pos',7]
		mat `pval_mat'[1,2]=results[`t2_pos',7]
		estadd mat mht=`pval_mat': `est'
	}
}
cap mat drop `pval_mat'

* Export regression results for mechanisms in fu1
esttab _all using "$results_tab/fu1_mechanisms.tex", replace star(* 0.10 ** 0.05 *** 0.01) cells(b(fmt(2) star) se(par) mht(fmt(3) par([ ]))) ///
	keep(t1 t2) label booktabs nomtitles collabels(none) nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mlabels("Business \\ practices" "Personal \\ initiative" "Capital and \\ labor inputs" "Introduced \\ innovation" "Loan \\ requested", prefix(\makecell{) suffix(}))




*** Table 5: Mechanisms (12-month follow-up) ***

* Compute regression results for mechanisms in fu2
eststo clear
foreach var in business_practices_index personal_initiative_index inputs_index innovation loan_requested {
	_eststo b_`var': reg fu2_`var' t1 t2 m_`var' d_`var' $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean=r(mean) : b_`var'
}

* Export regression results for mechanisms in fu2
esttab _all using "$results_tab/fu2_mechanisms.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(%5.2fc) se(%5.2fc) ///
	keep(t1 t2) label booktabs nomtitles nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mlabels("Business \\ practices" "Personal \\ initiative" "Capital and \\ labor inputs" "Introduced \\ innovation" "Loan \\ requested", prefix(\makecell{) suffix(})) ///
	substitute("-0.00" "0.00" "_" "\_" "$" "\$")




*** Table 6: Self-reported measures of soft skills targeted by the training (12-month follow-up) ***

* Compute regression results for measures of soft skills in fu2
eststo clear
foreach var in grit_index perseverance_aps_index perseverance_index personal_initiative_index future_orient_index barriers_index softskills_index {
	if regexm("`var'","perseverance") local base_controls "m_perseverance d_perseverance"
	else if regexm("`var'","initiative") local base_controls "m_personal_initiative_index d_personal_initiative_index"
	else local base_controls ""
	_eststo `var': reg fu2_`var' t1 t2 `base_controls' $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Add corrections for multiple hypothesis testing
tempname pval_mat
if int(c(version))>=15 {
	mhtexp fu2_grit_index fu2_perseverance_aps_index fu2_perseverance_index fu2_personal_initiative_index fu2_future_orient_index fu2_barriers_index, treatment(treatment)
	forvalues i=1/6 {
		local est: word `i' of grit_index perseverance_aps_index perseverance_index personal_initiative_index future_orient_index barriers_index
		local t1_pos=`i'*2-1
		local t2_pos=`i'*2
		mat `pval_mat'=J(1,2,.)
		mat colnames `pval_mat' = t1 t2
		mat `pval_mat'[1,1]=results[`t1_pos',7]
		mat `pval_mat'[1,2]=results[`t2_pos',7]
		estadd mat mht=`pval_mat' : `est'
	}
}
cap mat drop `pval_mat'

* Export regression results for soft skills in fu2
esttab _all using "$results_tab/fu2_personality_oth_B.tex", replace star(* 0.10 ** 0.05 *** 0.01) cells(b(star fmt(2)) se(par) mht(par([ ]) fmt(3))) ///
	keep(t1 t2) label booktabs nomtitles collabels(none) nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	posthead("&Grit&\makecell{Perseverance \\ (APS)}&Perseverance&\makecell{Personal \\ initiative}&\makecell{Future \\ orientation}" ///
		"&\makecell{Barriers \\ index}&\makecell{Soft skills \\ index}\\" "\midrule") ///
	substitute("-0.00" "0.00" "_" "\_" "$" "\$")




*** Table 7: Choice of difficult task in Game 1 (12-month follow-up) ***

* Compute regression results for the easy/difficult choice in Game 1
eststo clear
forvalues i=3/6 {
	_eststo r_`i': reg fu2_g1_r`i'_difficult t1 t2 $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_g1_r`i'_difficult if treatment==0
	estadd scalar control_mean=r(mean)
}

* Compute regression results for difficult in all rounds, number of difficult rounds and playing difficult for next wave
_eststo all: reg fu2_g1_all_difficult t1 t2 $controls_md i.strata i.fu2_month_interview, robust
test t1=t2
estadd scalar test_equality=r(p)
summ fu2_g1_all_difficult if treatment==0
estadd scalar control_mean=r(mean)
_eststo numb: reg fu2_g1_number_difficult t1 t2 $controls_md i.strata i.fu2_month_interview, robust
test t1=t2
estadd scalar test_equality=r(p)
summ fu2_g1_number_difficult if treatment==0
estadd scalar control_mean=r(mean)
_eststo next: reg fu2_g1_difficult_nextwave t1 t2 $controls_md i.strata i.fu2_month_interview, robust
test t1=t2
estadd scalar test_equality=r(p)
summ fu2_g1_difficult_nextwave if treatment==0
estadd scalar control_mean=r(mean)
_eststo index: reg fu2_g1_difficult_index t1 t2 $controls_md i.strata i.fu2_month_interview, robust
test t1=t2
estadd scalar test_equality=r(p)
summ fu2_g1_difficult_index if treatment==0
estadd scalar control_mean=r(mean)

* Add corrections for multiple hypothesis testing
tempname pval_mat
if int(c(version))>=15 {
	mhtexp fu2_g1_r3_difficult fu2_g1_r4_difficult fu2_g1_r5_difficult fu2_g1_r6_difficult fu2_g1_all_difficult fu2_g1_number_difficult fu2_g1_difficult_nextwave, treatment(treatment)
	forvalues i=1/7 {
		local est: word `i' of r_3 r_4 r_5 r_6 all numb next
		local t1_pos=`i'*2-1
		local t2_pos=`i'*2
		mat `pval_mat'=J(1,2,.)
		mat colnames `pval_mat' = t1 t2
		mat `pval_mat'[1,1]=results[`t1_pos',7]
		mat `pval_mat'[1,2]=results[`t2_pos',7]
		estadd mat mht=`pval_mat': `est'
	}
}
cap mat drop `pval_mat'

* Export regression results for the easy/difficult choice in Game 1
esttab _all using "$results_tab/fu2_game1.tex", replace star(* 0.10 ** 0.05 *** 0.01) cells(b(fmt(2) star) se(par) mht(fmt(3) par([ ]))) ///
	keep(t1 t2) label booktabs nomtitles collabels(none) nonumbers nonotes nogaps ///
	mgroups("Chose difficult in Game 1" "\multirow{3}{*}[-3pt]{\makecell{Difficult \\ task \\ index}}", pattern(1 0 0 0 0 0 0 1) span ///
		prefix(\multicolumn{@span}{c}{) suffix(}) begin("&(1)&(2)&(3)&(4)&(5)&(6)&(7)&(8)\\") end("\cmidrule(lr){2-8}")) ///
	posthead("&Round 3&Round 4&Round 5&Round 6&All rounds&\makecell{Num. of \\ rounds}&Next wave\\" "\midrule") ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	substitute("-0.00" "0.00" "_" "\_" "$" "\$")




*** Table 8: Differential impacts on main outcomes by gender (3-month follow-up) ***

* Generate interaction term
preserve
foreach var in t1 t2 {
	gen `var'_female=`var'*female
	lab var `var'_female "`: var lab `var'' $\times$ female"
}

* Compute regression results for heterogeneity by gender in fu1
eststo clear
foreach var in has_business pos_profits_lastm sales_profits_index {
	_eststo `var': reg fu1_`var' t1 t2 female t1_female t2_female m_`var' d_`var' $controls_md i.strata i.fu1_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu1_`var' if treatment==0 & female==1
	estadd scalar female_mean=r(mean)
	summ fu1_`var' if treatment==0 & female==0
	estadd scalar male_mean=r(mean)
}

* Export regression results for heterogeneity by gender in fu1
esttab _all using "$results_tab/fu1_main_outcomes_het_female.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1* t2*) label booktabs nonotes nogaps ///
	stats(female_mean male_mean test_equality N, labels("Mean control women" "Mean control men" "P-value equal t.e. for men" "Observations") fmt(2 2 3 %9.0fc)) ///
	mlabels("Firm survival" "Positive profits" "Sales and profits index")
restore




***************
*** Figures ***
***************


*** Figure 1a: Quantile treatment effects on sales and profits index (3-month follow-up) ***

* Expand factor variables (not allowed by qreg2)
preserve
xi i.strata i.fu1_month_interview, prefix(fe_)

* Compute results for each quantile and store in a matrix
tempname quant_mat
forvalues i=.05(.05)1 {
	qreg2 fu1_sales_profits_index t1 t2 m_sales_profits_index d_sales_profits_index $controls_md fe_*, quantile(`i')	// no need to specify robust with qreg2, already correct for heteroskedasticity
	mat `quant_mat'=nullmat(`quant_mat')\(`i'*100,_b[t1],_b[t2],_b[t1]-1.96*_se[t1],_b[t1]+1.96*_se[t1],_b[t2]-1.96*_se[t2],_b[t2]+1.96*_se[t2])
}
mat colnames `quant_mat' = percentile t1_coeff t2_coeff t1_ci_l t1_ci_u t2_ci_l t2_ci_u
svmat `quant_mat', names(col)
cap mat drop `quant_mat'

* Set font type
cap graph set window fontface "Times New Roman"

* Generate graphs for Treatment 1
twoway (line t1_coeff percentile, lcolor(navy) lwidth(thick) lpattern(shortdash)) ///
	(rline t1_ci_l t1_ci_u percentile, lcolor(navy)), ///
	scheme(s1color) xtitle("Percentile") xlabel(10(10)90) ///
	yscale(range(-.5 .7) axis(1)) ylabel(-.4(.2).6, angle(0) format(%3.1fc)) ///
	legend(label(1 "Soft-skills training (T1)") label(2 "95% CI for T1") symxsize(*.5)) ///
	yline(0, lcolor(black)) name(fu1_quantile_t1, replace)

* Generate graphs for Treatment 2
twoway (line t2_coeff percentile, lcolor(cranberry) lwidth(thick) lpattern(longdash) yaxis(1 2)) ///
	(rline t2_ci_l t2_ci_u percentile, lcolor(cranberry) lpattern(dash_dot) yaxis(1 2)), ///
	scheme(s1color) xtitle("Percentile") xlabel(10(10)90) ///
	yscale(range(-.5 .7) axis(1)) yscale(range(-.5 .7) axis(2)) ylabel(none, axis(1)) ylabel(-.4(.2).6, angle(0) format(%3.1fc) axis(2)) ///
	legend(label(1 "Combined training (T1)") label(2 "95% CI for T1") symxsize(*.5)) ///
	yline(0, lcolor(black) axis(2)) name(fu1_quantile_t2, replace)

* Combine and export the two graphs
graph combine fu1_quantile_t1 fu1_quantile_t2, xsize(10) altshrink graphregion(margin(none))
graph export "$results_fig/fu1_quantile_treat_eff.pdf", replace
restore




*** Figure 1b: Quantile treatment effects on sales and profits index (12-month follow-up) ***

* Expand factor variables (not allowed by qreg2)
preserve
xi i.strata i.fu2_month_interview, prefix(fe_)

* Compute results for each quantile and store in a matrix
cap mat drop mat_quantiles
forvalues i=.05(.05)1 {
	qreg2 fu2_sales_profits_index t1 t2 m_sales_profits_index d_sales_profits_index $controls_md fe_*, quantile(`i')	// no need to specify robust with qreg2, already correct for heteroskedasticity
	mat mat_quantiles=nullmat(mat_quantiles)\(`i'*100,_b[t1],_b[t2],_b[t1]-1.96*_se[t1],_b[t1]+1.96*_se[t1],_b[t2]-1.96*_se[t2],_b[t2]+1.96*_se[t2])
}
mat colnames mat_quantiles = percentile t1_coeff t2_coeff t1_ci_l t1_ci_u t2_ci_l t2_ci_u
svmat mat_quantiles, names(col)

* Set font type
cap graph set window fontface "Times New Roman"

* Generate graphs for Treatment 1
twoway (line t1_coeff percentile, lcolor(navy) lwidth(thick) lpattern(shortdash)) ///
	(rline t1_ci_l t1_ci_u percentile, lcolor(navy)), ///
	scheme(s1color) xtitle("Percentile") xlabel(10(10)90) ///
	yscale(range(-.8 .4)) ylabel(-.8(.2).4, angle(0) format(%3.1fc)) ///
	legend(label(1 "Soft-skills training (T1)") label(2 "95% CI for T1") symxsize(*.5)) ///
	yline(0, lcolor(black)) name(fu2_quantile_t1, replace)

* Generate graphs for Treatment 2
twoway (line t2_coeff percentile, lcolor(cranberry) lwidth(thick) lpattern(longdash) yaxis(1 2)) ///
	(rline t2_ci_l t2_ci_u percentile, lcolor(cranberry) lpattern(dash_dot) yaxis(1 2)), ///
	scheme(s1color) xtitle("Percentile") xlabel(10(10)90) ///
	yscale(range(-.8 .4) axis(1)) yscale(range(-.8 .4) axis(2)) ylabel(none, axis(1)) ylabel(-.8(.2).4, angle(0) format(%3.1fc) axis(2)) ///
	legend(label(1 "Combined training (T1)") label(2 "95% CI for T1") symxsize(*.5)) ///
	yline(0, lcolor(black) axis(2)) name(fu2_quantile_t2, replace)

* Combine and export the two graphs
graph combine fu2_quantile_t1 fu2_quantile_t2, xsize(10) altshrink graphregion(margin(none))
graph export "$results_fig/fu2_quantile_treat_eff.pdf", replace
restore




***********************
*** Appendix tables ***
***********************


*** Table A2: Determinants of Attendance ***

* Compute regression results for attendance
eststo clear
foreach var of varlist atleast1 log_attend log_attend_second {
	_eststo: reg `var' t2 $all_covariates_m $all_covariates_d, robust
	estadd scalar test_equality=r(p)
	summ `var'
	estadd scalar control_mean=r(mean)
}

* Export regression results for attendance
esttab _all using "$results_tab/takeup.tex", replace star(* 0.10 ** 0.05 *** 0.01) cells((b(fmt(2) lab(Coeff.) star) se(lab(SE)))) ///
	drop(d_* _cons) nocon label booktabs nomtitles nonumbers nonotes nogaps varlabel(t2 "Combined training (T2)" m_register_bus "Business registered") ///
	mgroups("\makecell{Attended at least \\ 1 class}" "Log attendance" "\makecell{Log attendance \\ 2nd part}", pattern(1 1 1) span prefix(\multicolumn{@span}{c}{) suffix(}) ///
		erepeat(\cmidrule(lr){@span}) begin("&(1)&(2)&(3)&(4)&(5)&(6)\\")) ///	
	stats(control_mean r2_a N, labels("Mean (both treat. arms)" "Adj. R-squared" "Observations") fmt(2 3 %9.0fc))




*** Table A3: Components of the Sales and Profits Index (3-month follow-up) ***

* Compute regression results for main outcomes in follow-up 1 (unwinsorized and winsorized)
eststo clear
foreach x in "" win_ {
	foreach var in sales_lastm profits_lastm {
		if regexm("`var'","profits") local base_controls m_`x'profits_lastm d_`x'profits_lastm
		else if regexm("`var'","sales") local base_controls m_`x'sales_lastm d_`x'sales_lastm
		_eststo `x'`var': reg fu1_`x'`var' t1 t2 `base_controls' $controls_md i.strata i.fu1_month_interview if !mi(fu1_sales_profits_index), robust
		test t1=t2
		estadd scalar test_equality=r(p)
		summ fu1_`x'`var' if treatment==0 & !mi(fu1_sales_profits_index)
		estadd scalar control_mean_0=r(mean)
	}
}

* Compute regression results for main outcomes in follow-up 1 (IHS-transformed)
foreach var in sales_lastm profits_lastm {
	if regexm("`var'","profits") local base_controls m_ihs_profits_lastm d_ihs_profits_lastm
	else if regexm("`var'","sales") local base_controls m_ihs_sales_lastm d_ihs_sales_lastm
	eststo ihs_`var': reg fu1_ihs_`var' t1 t2 `base_controls' $controls_md i.strata i.fu1_month_interview if !mi(fu1_sales_profits_index), robust
	estadd mat results=r(table)					// store results in a separate matrix, so that esttab can apply a different format
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu1_ihs_`var' if treatment==0 & !mi(fu1_sales_profits_index)
	estadd scalar control_mean_2=r(mean)
}

* Export regression results for sales last month
esttab *sales_lastm using "$results_tab/fu1_subcomp_salesprofits.tex", replace star(* 0.10 ** 0.05 *** 0.01) keep(t1 t2) ///
	cells((b(pattern(1 1 0) fmt(%9.0fc) star) results[b](pattern(0 0 1) fmt(2) star)) (se(pattern(1 1 0) fmt(%9.0fc) par) results[se](pattern(0 0 1) fmt(2) par))) ///
	varlabels(, blist(t1 "\multicolumn{4}{l}{\textbf{Panel A. Sales last month}}\\")) label booktabs collabels(none) nonotes ///
	stats(control_mean_0 control_mean_2 test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") layout("@@" @ @) fmt(%9.0fc 2 3 %9.0fc)) ///
	mlabels("Not winsorized" "Winsorized" "IHS-transformed") prefoot("\addlinespace") postfoot("") ///
	substitute("_" "\_" "$" "\$" "@" "")

* Export regression results for profits last month
esttab *profits_lastm using "$results_tab/fu1_subcomp_salesprofits.tex", append star(* 0.10 ** 0.05 *** 0.01) keep(t1 t2) ///
	cells((b(pattern(1 1 0) fmt(%9.0fc) star) results[b](pattern(0 0 1) fmt(2) star)) (se(pattern(1 1 0) fmt(%9.0fc) par) results[se](pattern(0 0 1) fmt(2) par))) ///
	varlabels(, blist(t1 "\multicolumn{4}{l}{\textbf{Panel B. Profits last month}}\\")) label booktabs collabels(none) nomtitles nonumbers nonotes ///
	stats(control_mean_0 control_mean_2 test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") layout("@@" @ @) fmt(%9.0fc 2 3 %9.0fc)) ///
	prehead("") prefoot("\addlinespace") ///
	substitute("_" "\_" "$" "\$" "@" "")




*** Table A4: Components of the Sales and Profits Index (12-month follow-up) ***

* Compute regression results for main outcomes in follow-up 2 (unwinsorized and winsorized)
eststo clear
foreach x in "" win_ {
	foreach var in sales_lastm profits_lastm {
		if regexm("`var'","profits") local base_controls m_`x'profits_lastm d_`x'profits_lastm
		else if regexm("`var'","sales") local base_controls m_`x'sales_lastm d_`x'sales_lastm
		_eststo `x'`var': reg fu2_`x'`var' t1 t2 `base_controls' $controls_md i.strata i.fu2_month_interview if !mi(fu2_sales_profits_index), robust
		test t1=t2
		estadd scalar test_equality=r(p)
		summ fu2_`x'`var' if treatment==0 & !mi(fu2_sales_profits_index)
		estadd scalar control_mean_0=r(mean)
	}
}

* Compute regression results for main outcomes in follow-up 1 (IHS-transformed)
foreach var in sales_lastm profits_lastm {
	if regexm("`var'","profits") local base_controls m_ihs_profits_lastm d_ihs_profits_lastm
	else if regexm("`var'","sales") local base_controls m_ihs_sales_lastm d_ihs_sales_lastm
	eststo ihs_`var': reg fu2_ihs_`var' t1 t2 `base_controls' $controls_md i.strata i.fu2_month_interview if !mi(fu2_sales_profits_index), robust
	estadd mat results=r(table)					// store results in a separate matrix, so that esttab can apply a different format
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_ihs_`var' if treatment==0 & !mi(fu2_sales_profits_index)
	estadd scalar control_mean_2=r(mean)
}

* Export regression results for sales last month
esttab *sales_lastm using "$results_tab/fu2_subcomp_salesprofits.tex", replace star(* 0.10 ** 0.05 *** 0.01) keep(t1 t2) ///
	cells((b(pattern(1 1 0) fmt(%9.0fc) star) results[b](pattern(0 0 1) fmt(2) star)) (se(pattern(1 1 0) fmt(%9.0fc) par) results[se](pattern(0 0 1) fmt(2) par))) ///
	varlabels(, blist(t1 "\multicolumn{4}{l}{\textbf{Panel A. Sales last month}}\\")) label booktabs collabels(none) nonotes ///
	stats(control_mean_0 control_mean_2 test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") layout("@@" @ @) fmt(%9.0fc 2 3 %9.0fc)) ///
	mlabels("Not winsorized" "Winsorized" "IHS-transformed") prefoot("\addlinespace") postfoot("") ///
	substitute("_" "\_" "$" "\$" "@" "")

* Export regression results for profits last month
esttab *profits_lastm using "$results_tab/fu2_subcomp_salesprofits.tex", append star(* 0.10 ** 0.05 *** 0.01) keep(t1 t2) ///
	cells((b(pattern(1 1 0) fmt(%9.0fc) star) results[b](pattern(0 0 1) fmt(2) star)) (se(pattern(1 1 0) fmt(%9.0fc) par) results[se](pattern(0 0 1) fmt(2) par))) ///
	varlabels(, blist(t1 "\multicolumn{4}{l}{\textbf{Panel B. Profits last month}}\\")) label booktabs collabels(none) nomtitles nonumbers nonotes ///	
	stats(control_mean_0 control_mean_2 test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") layout("@@" @ @) fmt(%9.0fc 2 3 %9.0fc)) ///
	prehead("") prefoot("\addlinespace") ///
	substitute("_" "\_" "$" "\$" "@" "")




*** Table A5: Attrition ***

* Generate interaction terms
preserve
global interactions_all ""
global interactions_t1 ""
global interactions_t2 ""
foreach var of varlist $all_covariates {
	global interactions_all "$interactions_all t1_`var' t2_`var'"
	global interactions_t1 "$interactions_t1 t1_`var'"
	global interactions_t2 "$interactions_t2 t2_`var'"
	cap confirm new variable t1_`var' t2_`var'
	if _rc continue									// do not re-generate already existing interaction terms
	gen t1_`var'=t1*m_`var'
	gen t2_`var'=t2*m_`var'
	local old_label: var lab `var'
	lab var t1_`var' "T1 $\times$ `old_label'"
	lab var t2_`var' "T2 $\times$ `old_label'"
}

* Compute regression results for attrition
eststo clear
foreach var of varlist fu1_attriter fu2_attriter fu1_fu2_attriter {
	_eststo `var'_noint: reg `var' t1 t2 i.strata, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	_eststo `var'_withint: reg `var' t1 t2 $all_covariates_m $all_covariates_d $interactions_all, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	testparm $interactions_t1
	estadd scalar test_inter_t1=r(p)
	testparm $interactions_t2
	estadd scalar test_inter_t2=r(p)
	summ `var' if treatment==0
	estadd scalar control_mean=r(mean): `var'_noint `var'_withint
}

* Split variables to go in table A or B
global list_A=substr("$interactions_all",1,strpos("$interactions_all","t1_personal_initiative")-2)
global list_B=substr("$interactions_all",strpos("$interactions_all","t1_personal_initiative"),.)

* Export regression results for attrition
esttab _all using "$results_tab/attrition_A.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) not keep(t1 t2 $list_A) ///
	label booktabs nomtitles nonumbers noobs nonotes ///
	varlabels(t1 "Soft-skills training (T1)" t2 "Combined training (T2)", blist(t1_female "\addlinespace \multicolumn{7}{l}{\textbf{Panel A. Stratification variables}}\\" ///
		t1_age "\addlinespace \multicolumn{7}{l}{\textbf{Panel B. Owner characteristics}}\\")) ///
	mgroups("3-month follow-up" "12-month follow-up" "Both follow-ups", pattern(1 0 1 0 1 0) span prefix(\multicolumn{@span}{c}{) suffix(}) ///
		begin("&(1)&(2)&(3)&(4)&(5)&(6)\\" "&\multicolumn{6}{c}{Attriter}\\" "\cmidrule(lr){2-7}"))

* Export regression results for attrition
esttab _all using "$results_tab/attrition_B.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) not keep($list_B) ///
	label booktabs nomtitles nonumbers nonotes nogaps ///
	varlabels(,blist(t1_active_business "\addlinespace \multicolumn{7}{l}{\textbf{Panel C. Firm characteristics}}\\")) ///
	mgroups("3-month follow-up" "12-month follow-up" "Both follow-ups", pattern(1 0 1 0 1 0) span prefix(\multicolumn{@span}{c}{) suffix(}) ///
		begin("&(1)&(2)&(3)&(4)&(5)&(6)\\" "&\multicolumn{6}{c}{Attriter}\\" "\cmidrule(lr){2-7}")) ///
	stats(control_mean test_equality test_inter_t1 test_inter_t2 N, fmt(2 3 3 3 %9.0fc) ///
		labels("Mean control group" "P-value equal t.e." "P-value joint sign. T1 inter." "P-value joint sign. T2 inter." "Observations"))

* Drop interaction terms
restore




*** Table A6: Effect on comprehensive list of business practices (12-month follow-up) ***

* Compute regression results for sub-components of business practices in fu2
eststo clear
rename fu2_all_business_practices_index fu2_all_busprac
foreach var in all_busprac marketing_index accounting_index operat_perform_index info_opportunity_index hr_index {
	_eststo `var': reg fu2_`var' t1 t2 m_business_practices_index d_business_practices_index $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean=r(mean)
}
rename fu2_all_busprac fu2_all_business_practices_index

* Export regression results for sub-components of business practices in fu2
esttab _all using "$results_tab/fu2_subcomp_buspraccomplete.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2) label booktabs nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mtitles("\makecell{All business \\ practices}" "Marketing" "Accounting" "\makecell{Operations \\ management}" ///
		"\makecell{Information \\ seeking}" "\makecell{Hum. res. \\ management}")




*** Table A7: Mediation analysis (3-month follow-up) ***

* Compute mediation results in fu1
preserve
set obs 20000
set seed 20180913
eststo clear
foreach var in business_practices_index personal_initiative_index inputs_index innovation loan_requested {
	* Compute results as normal regression
	_eststo `var': reg fu1_sales_profits_index t1 t2 fu1_`var' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview, robust
	summ fu1_`var' if treatment==0
	estadd scalar control_mean=r(mean)
	* Compute CI separately by treatment arm
	forvalues i=1/2 {
		* Compute results for two channels with sureg
		sureg (a`i': fu1_`var' t`i' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview) ///
			(b`i': fu1_sales_profits_index fu1_`var' t`i' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview)
		* Generate random normal distributions and their product
		tempvar a`i' b`i' prod`i'
		gen `a`i'' =rnormal(_b[a`i':t`i'],_se[a`i':t`i'])
		gen `b`i'' =rnormal(_b[b`i':fu1_`var'],_se[b`i':fu1_`var'])
		gen `prod`i''=`a`i''*`b`i''
		* Store confidence intervals
		centile `prod`i'', cent(2.5 97.5)
		estadd scalar t`i'_ci_l=r(c_1) : `var'
		estadd scalar t`i'_ci_u=r(c_2) : `var'
		* Drop random variables
		drop `a`i'' `b`i'' `prod`i''
	}
}

* Export mediation results in fu1
esttab _all	using "$results_tab/fu1_mediation.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2 fu1_business_practices_index fu1_personal_initiative_index fu1_inputs_index fu1_innovation fu1_loan_requested) ///
	label booktabs nonumbers nonotes nogaps ///
	varlabels(fu1_business_practices_index "Business practices" fu1_personal_initiative_index "Personal initiative" fu1_inputs_index "Capital and labor inputs" ///
		fu1_innovation "Introduced innovation" fu1_loan_requested "Loan requested" fu1_loan_approved "Loan approved") ///
	stats(control_mean t1_ci_l t1_ci_u t2_ci_l t2_ci_u N, labels("Mean MV control group" "Monte Carlo 95\% C.I. for T1" "Monte Carlo 95\% C.I. for T2" "Observations") ///
		fmt(2 3 3 3 3 %9.0fc) layout(@ "[@,@]" "[@,@]" @)) ///
	mgroups("Effect on sales and profits index", span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span}) begin("&(1)&(2)&(3)&(4)&(5)\\")) ///
	mlabels("MV: Business \\ practices" "MV: Personal \\ initiative" "MV: Capital and \\ labor inputs" "MV: Introduced \\ innovation" "MV: Loan \\ requested", prefix(\makecell{) suffix(}))
restore




*** Table A8: Other personality traits (12-month follow-up) ***

* Compute regression results for other personality traits in fu2
eststo clear
foreach var in metacognition_index need_cognition_index entrep_greed_index passion_index personality_index {
	_eststo `var': reg fu2_`var' t1 t2 $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Add corrections for multiple hypothesis testing
tempname pval_mat
if int(c(version))>=15 {
	mhtexp fu2_metacognition_index fu2_need_cognition_index fu2_entrep_greed_index fu2_passion_index, treatment(treatment)
	forvalues i=1/4 {
		local est: word `i' of metacognition_index need_cognition_index entrep_greed_index passion_index
		local t1_pos=`i'*2-1
		local t2_pos=`i'*2
		mat `pval_mat'=J(1,2,.)
		mat colnames `pval_mat' = t1 t2
		mat `pval_mat'[1,1]=results[`t1_pos',7]
		mat `pval_mat'[1,2]=results[`t2_pos',7]
		estadd mat mht=`pval_mat': `est'
	}
}
cap mat drop `pval_mat'

* Export regression results for other personality traits in fu2
esttab _all using "$results_tab/fu2_personality_oth_A.tex", replace star(* 0.10 ** 0.05 *** 0.01) cells(b(fmt(2) star) se(par) mht(fmt(3) par([ ]))) ///
	keep(t1 t2) label booktabs collabels(none) nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(%5.2fc %9.3fc %9.0fc)) ///
	mtitles("Metacognition" "\makecell{Need for \\ cognition}" "\makecell{Entrepr. \\ greed}" "Passion" "\makecell{Oth. traits \\ index}") ///
	substitute("-0.00" "0.00" "_" "\_" "$" "\$")




***********************
*** Online Appendix ***
***********************



*** Table OA1: Robustness of main results to differential attrition (3-month follow-up) ***

// In fu1: t1 and t2 each we have 20 fewer attriters than control

* Set seed (for random numbers to select attriters to replace values)
preserve
set seed 20180904

* Assume all attritors are from top/bottom of distribution in fu1 (Lee bounds)
clonevar top=fu1_sales_profits_index
clonevar btm=fu1_sales_profits_index
egen rank_top=rank(-fu1_sales_profits_index) if fu1_attriter==0 & !missing(fu1_sales_profits_index), by(treatment) unique
egen rank_btm=rank(fu1_sales_profits_index) if fu1_attriter==0 & !missing(fu1_sales_profits_index), by(treatment) unique
replace top=. if (treatment==1 | treatment==2) & rank_top<=20
replace btm=. if (treatment==1 | treatment==2) & rank_btm<=20

* Assume all attitors are at the 95%, 90% or 75% percentiles in fu1
gen random=runiform()
egen rank=rank(random) if treatment==0 & fu1_attriter==1 & missing(fu1_sales_profits_index), unique
foreach perc in p95 p75 p50 {
	clonevar `perc'=fu1_sales_profits_index
	summ fu1_sales_profits_index if treatment==1, de
	replace `perc'=r(`perc') if treatment==0 & rank<=20
}

* Assume attritors are from mean +/- 0.10/0.25 standard deviations (Horowitz and Manski bounds)
clonevar l010=fu1_sales_profits_index
clonevar u010=fu1_sales_profits_index
clonevar l025=fu1_sales_profits_index
clonevar u025=fu1_sales_profits_index
foreach t in t1 t2 {
	summ fu1_sales_profits_index if `t'==1
	replace l010=r(mean)-0.10*r(sd) if fu1_attriter==1 & missing(fu1_sales_profits_index) & `t'==1
	replace u010=r(mean)+0.10*r(sd) if fu1_attriter==1 & missing(fu1_sales_profits_index) & `t'==1
	replace l025=r(mean)-0.25*r(sd) if fu1_attriter==1 & missing(fu1_sales_profits_index) & `t'==1
	replace u025=r(mean)+0.25*r(sd) if fu1_attriter==1 & missing(fu1_sales_profits_index) & `t'==1
}
summ fu1_sales_profits_index if treatment==0
replace l010=r(mean)+0.10*r(sd) if fu1_attriter==1 & missing(fu1_sales_profits_index) & treatment==0
replace u010=r(mean)-0.10*r(sd) if fu1_attriter==1 & missing(fu1_sales_profits_index) & treatment==0
replace l025=r(mean)+0.25*r(sd) if fu1_attriter==1 & missing(fu1_sales_profits_index) & treatment==0
replace u025=r(mean)-0.25*r(sd) if fu1_attriter==1 & missing(fu1_sales_profits_index) & treatment==0

* Assign 'unknown' as month of the interview for attriters
replace fu1_month_interview=99 if fu1_attriter==1

* Compute regression results for attrition bounds in fu1
eststo clear
foreach x in fu1_sales_profits_index btm top p95 p75 p50 l025 l010 u010 u025 {
	_eststo `x': reg `x' t1 t2 m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ `x' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Export regression results for sales
esttab _all using "$results_tab/fu1_attrition_bounds.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2) label booktabs nomtitles nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	posthead("&\multicolumn{10}{c}{Sales and profit index}\\" "\cmidrule(lr){2-11}" "&\multirow{3}{*}[-2pt]{\makecell{Main \\ spec.}}" ///
		"&\multicolumn{2}{c}{Trimming treated}&\multicolumn{3}{c}{Imputing control}&\multicolumn{4}{c}{Imputing with mean}\\" ///
		"\cmidrule(lr){3-4}\cmidrule(lr){5-7}\cmidrule(lr){8-11}" "&&Bottom&Top&95th pc.&75th pc.&50th pc.&-0.25 SD&-0.10 SD&+0.10 SD&+0.25 SD\\" ///
		"&& UB & LB &\multicolumn{3}{c}{LB}&\multicolumn{2}{c}{LB}&\multicolumn{2}{c}{UB}\\" "\midrule") ///
	substitute("-0.00" "0.00" "_" "\_" "$" "\$")

* Drop new variables
restore




*** Table OA2: Robustness of main results to differential attrition (12-month follow-up) ***

// In fu2: t2 has 2 more (!) attriters than control, t1 has 9 less

* Set seed (for random numbers to select attriters to replace values)
preserve
set seed 20180904

* Assume all attritors are from top/bottom of distribution in fu2 (Lee bounds)
foreach var in /*win_sales_lastm win_profits_lastm*/ sales_profits_index {
	clonevar top=fu2_sales_profits_index
	clonevar btm=fu2_sales_profits_index
	egen rank_top=rank(-fu2_sales_profits_index) if fu2_attriter==0 & !missing(fu2_sales_profits_index), by(treatment) unique
	egen rank_btm=rank(fu2_sales_profits_index) if fu2_attriter==0 & !missing(fu2_sales_profits_index), by(treatment) unique
	replace top=. if treatment==1 & rank_top<=9
	replace btm=. if treatment==1 & rank_btm<=9
}

* Assume all attitors are at the 95%, 90% or 75% percentiles in fu2
foreach var in /*win_sales_lastm win_profits_lastm*/ sales_profits_index {
	gen random=runiform()
	egen rank=rank(random) if treatment==0 & fu2_attriter==1 & missing(fu2_sales_profits_index), unique
	foreach perc in p5 p25 p50 {
		clonevar `perc'=fu2_sales_profits_index
		summ fu2_sales_profits_index if treatment==1, de
		replace `perc'=r(`perc') if treatment==0 & rank<=20
	}
}

* Assume attritors are from mean +/- 0.10/0.25 standard deviations (Horowitz and Manski bounds)
foreach var in /*win_sales_lastm win_profits_lastm*/ sales_profits_index {
	clonevar l010=fu2_sales_profits_index
	clonevar u010=fu2_sales_profits_index
	clonevar l025=fu2_sales_profits_index
	clonevar u025=fu2_sales_profits_index
	foreach t in t1 t2 {
		summ fu2_sales_profits_index if `t'==1
		replace l010=r(mean)-0.10*r(sd) if fu2_attriter==1 & missing(fu2_sales_profits_index) & `t'==1
		replace u010=r(mean)+0.10*r(sd) if fu2_attriter==1 & missing(fu2_sales_profits_index) & `t'==1
		replace l025=r(mean)-0.25*r(sd) if fu2_attriter==1 & missing(fu2_sales_profits_index) & `t'==1
		replace u025=r(mean)+0.25*r(sd) if fu2_attriter==1 & missing(fu2_sales_profits_index) & `t'==1
	}
	summ fu2_sales_profits_index if treatment==0
	replace l010=r(mean)+0.10*r(sd) if fu2_attriter==1 & missing(fu2_sales_profits_index) & treatment==0
	replace u010=r(mean)-0.10*r(sd) if fu2_attriter==1 & missing(fu2_sales_profits_index) & treatment==0
	replace l025=r(mean)+0.25*r(sd) if fu2_attriter==1 & missing(fu2_sales_profits_index) & treatment==0
	replace u025=r(mean)-0.25*r(sd) if fu2_attriter==1 & missing(fu2_sales_profits_index) & treatment==0
}

* Assign 'unknown' as month of the interview for attriters
replace fu2_month_interview=99 if fu2_attriter==1

* Compute regression results for attrition bounds in fu2
eststo clear
foreach var in /*win_sales_lastm win_profits_lastm*/ sales_profits_index {
	foreach x in fu2_sales_profits_index btm top p5 p25 p50 l025 l010 u010 u025 {
		_eststo `x': reg `x' t1 t2 m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu2_month_interview, robust
		test t1=t2
		estadd scalar test_equality=r(p)
		summ `x' if treatment==0
		estadd scalar control_mean=r(mean)
	}
}

* Export regression results for sales
esttab _all using "$results_tab/fu2_attrition_bounds.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2) label booktabs nomtitles nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	posthead("&\multicolumn{10}{c}{Sales and profit index}\\" "\cmidrule(lr){2-11}" "&\multirow{3}{*}[-2pt]{\makecell{Main \\ spec.}}" ///
		"&\multicolumn{2}{c}{Trimming treated}&\multicolumn{3}{c}{Imputing control}&\multicolumn{4}{c}{Imputing with mean}\\" ///
		"\cmidrule(lr){3-4}\cmidrule(lr){5-7}\cmidrule(lr){8-11}" "&&Bottom&Top&5th pc.&25th pc.&50th pc.&-0.25 SD&-0.10 SD&+0.10 SD&+0.25 SD\\" ///
		"&& UB & LB &\multicolumn{3}{c}{UB}&\multicolumn{2}{c}{LB}&\multicolumn{2}{c}{UB}\\" "\midrule") ///
	substitute("-0.00" "0.00" "_" "\_" "$" "\$")

* Drop new variables
restore




*** Table OA3: Correcting for Attrition with IPW ***

* Compute regression results for fu1 and fu2
eststo clear
_eststo fu1_main: reg fu1_sales_profits_index t1 t2 m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview, robust
test t1=t2
estadd scalar test_equality=r(p)
_eststo fu2_main: reg fu2_sales_profits_index t1 t2 m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu2_month_interview, robust
test t1=t2
estadd scalar test_equality=r(p)
_eststo fu1_ipaw: reg fu1_sales_profits_index t1 t2 m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview [weight=fu1_att_weight], robust
test t1=t2
estadd scalar test_equality=r(p)
_eststo fu2_ipaw: reg fu2_sales_profits_index t1 t2 m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu2_month_interview [weight=fu2_att_weight], robust
test t1=t2
estadd scalar test_equality=r(p)

* Add mean for control group to stored results
summ fu1_sales_profits_index if treatment==0
estadd scalar control_mean=r(mean) : fu1_main fu1_ipaw
summ fu2_sales_profits_index if treatment==0
estadd scalar control_mean=r(mean) : fu2_main fu2_ipaw

* Export regression results for main outcomes in fu1
esttab _all using "$results_tab/bywave_main_outcomes_ipaw_reduced.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2) label booktabs nonumbers nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mgroups("Main spec." "IPW", pattern(1 0 1 0) span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span}) ///
		begin("&(1)&(2)&(3)&(4)\\" "&\multicolumn{4}{c}{Sales and profits index}\\" "\cmidrule(lr){2-5}")) ///
	mlabels("3-month \\ follow-up" "12-month \\ follow-up" "3-month \\ follow-up" "12-month \\ follow-up", prefix(\makecell{) suffix(})) ///
	substitute("-0.00" "0.00" "_" "\_" "$" "\$")




*** Table OA4: Sub-components of business practices (3-month follow-up) ***

* Compute regression results for sub-components of business practices in fu1
eststo clear
forvalues i=1/7 {
	_eststo busprac_`i': reg fu1_busprac_`i' t1 t2 m_busprac_`i' d_busprac_`i' $controls_md i.strata i.fu1_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu1_busprac_`i' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Add corrections for multiple hypothesis testing
tempname pval_mat
if int(c(version))>=15 {
	mhtexp fu1_busprac_1 fu1_busprac_2 fu1_busprac_3 fu1_busprac_4 fu1_busprac_5 fu1_busprac_6 fu1_busprac_7, treatment(treatment)
	forvalues i=1/7 {
		local est: word `i' of busprac_1 busprac_2 busprac_3 busprac_4 busprac_5 busprac_6 busprac_7
		local t1_pos=`i'*2-1
		local t2_pos=`i'*2
		mat `pval_mat'=J(1,2,.)
		mat colnames `pval_mat' = t1 t2
		mat `pval_mat'[1,1]=results[`t1_pos',7]
		mat `pval_mat'[1,2]=results[`t2_pos',7]
		estadd mat mht=`pval_mat': `est'
	}
}
cap mat drop `pval_mat'

* Export regression results for sub-components of business practices in fu1
esttab _all using "$results_tab/fu1_subcomp_busprac.tex", replace star(* 0.10 ** 0.05 *** 0.01) cells(b(fmt(2) star) se(par) mht(fmt(3) par([ ]))) ///
	keep(t1 t2) label booktabs nomtitles collabels(none) nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mlabels("Asked \\ customers" "Special \\ offer" "Negotiated \\ prices" "Compared \\ prices" ///
		"Determined \\ profits per item" "Recorded all \\ transactions" "Set sales \\ target", prefix(\makecell{) suffix(}))




*** Table OA5: Sub-components of business practices (12-month follow-up) ***

* Compute regression results for sub-components of business practices in fu2
eststo clear
forvalues i=1/7 {
	local j: word `i' of 3 6 8 9 15 12 20
	_eststo prac_`i': reg fu2_busprac_`j' t1 t2 m_busprac_`i' d_busprac_`i' $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_busprac_`j' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Export regression results for sub-components of business practices in fu2
esttab _all using "$results_tab/fu2_subcomp_busprac.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2) label booktabs nomtitles nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mlabels("Asked \\ customers" "Special \\ offer" "Negotiated \\ prices" "Compared \\ prices" ///
		"Determined \\ profits per item" "Recorded all \\ transactions" "Compared sales \\ to targets", prefix(\makecell{) suffix(}))




*** Table OA6: Sub-components of capital and labor inputs (3-month follow-up) ***

* Compute regression results for sub-components of capital and labor index in fu1
eststo clear
foreach var in total_employees employees_fulltime employees_parttime investment {
	if "`var'"=="investment" local base_controls ""
	else local base_controls "m_`var' d_`var'"
	_eststo `var': reg fu1_`var' t1 t2 `base_controls' $controls_md i.strata i.fu1_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu1_`var' if treatment==0
	estadd scalar control_mean_2=r(mean)
}

* Compute regression results for investment amount
eststo win_investment_amount: reg fu1_win_investment_amount t1 t2 $controls_md i.strata i.fu1_month_interview, robust
estadd mat results=r(table)					// store results in a separate matrix, so that esttab can apply a different format
test t1=t2
estadd scalar test_equality=r(p)
summ fu1_win_investment_amount if treatment==0
estadd scalar control_mean_0=r(mean)

* Add corrections for multiple hypothesis testing
tempname pval_mat
if int(c(version))>=15 {
	mhtexp fu1_total_employees fu1_employees_fulltime fu1_employees_parttime fu1_investment fu1_win_investment_amount, treatment(treatment)
	forvalues i=1/5 {
		local est: word `i' of total_employees employees_fulltime employees_parttime investment win_investment_amount
		local t1_pos=`i'*2-1
		local t2_pos=`i'*2
		mat `pval_mat'=J(1,2,.)
		mat colnames `pval_mat' = t1 t2
		mat `pval_mat'[1,1]=results[`t1_pos',7]
		mat `pval_mat'[1,2]=results[`t2_pos',7]
		estadd mat mht=`pval_mat': `est'
	}
}
cap mat drop `pval_mat'

* Export regression results for sub-components of capital and labor index in fu1
esttab _all using "$results_tab/fu1_subcomp_capitallabor.tex", replace star(* 0.10 ** 0.05 *** 0.01) ///
	cells((b(pattern(1 1 1 1 0) fmt(2) star) results[b](pattern(0 0 0 0 1) fmt(%9.0fc) star)) (se(pattern(1 1 1 1 0) fmt(2) par) results[se](pattern(0 0 0 0 1) fmt(%9.0fc) par)) ///
		(mht(pattern(1 1 1 1 0) fmt(3) par([ ])) mht(pattern(0 0 0 0 1) fmt(3) par([ ])))) ///
	keep(t1 t2) label booktabs nomtitles collabels(none) nonotes nogaps ///
	stats(control_mean_2 control_mean_0 test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") layout("@@" @ @) fmt(2 %9.0fc 3 %9.0fc)) ///
	mlabels("Total \\ employees" "Full-time \\ employees" "Part-time \\ employees" "Investment" "Investment \\ amount", prefix(\makecell{) suffix(})) ///
	substitute("@" "" "_" "\_" "$" "\$")




*** Table OA7: Sub-components of capital and labor inputs (12-month follow-up) ***

* Compute regression results for sub-components of capital and labor index in fu2
eststo clear
foreach var in total_employees employees_fulltime employees_parttime investment {
	if "`var'"=="investment" local base_controls ""
	else local base_controls "m_`var' d_`var'"
	_eststo `var': reg fu2_`var' t1 t2 `base_controls' $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean_2=r(mean)
}

* Compute regression results for investment amount
eststo win_investment_amount: reg fu2_win_investment_amount t1 t2 $controls_md i.strata i.fu2_month_interview, robust
estadd mat results=r(table)					// store results in a separate matrix, so that esttab can apply a different format
test t1=t2
estadd scalar test_equality=r(p)
summ fu2_win_investment_amount if treatment==0
estadd scalar control_mean_0=r(mean)

* Export regression results for sub-components of capital and labor index in fu2
esttab _all using "$results_tab/fu2_subcomp_capitallabor.tex", replace star(* 0.10 ** 0.05 *** 0.01) ///
	cells((b(pattern(1 1 1 1 0) fmt(2) star) results[b](pattern(0 0 0 0 1) fmt(%9.0fc) star)) (se(pattern(1 1 1 1 0) fmt(2) par) results[se](pattern(0 0 0 0 1) fmt(%9.0fc) par))) ///
	keep(t1 t2) label booktabs nomtitles collabels(none) nonotes nogaps ///
	stats(control_mean_2 control_mean_0 test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") layout("@@" @ @) fmt(2 %9.0fc 3 %9.0fc)) ///
	mlabels("Total \\ employees" "Full-time \\ employees" "Part-time \\ employees" "Investment" "Investment \\ amount", prefix(\makecell{) suffix(})) ///
	substitute("@" "" "_" "\_" "$" "\$")




*** Table OA8: Other Intermediate Outcomes (12-month follow-up) ***

* Compute regression results for other intermediate outcomes in fu2
eststo clear
foreach var in partic_decisionmaking own_decisionmaking register_bus networking_index {
	if regexm("`var'","register") local base_controls m_register_bus d_register_bus
	else local base_controls ""
	_eststo `var': reg fu2_`var' t1 t2 `base_controls' $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Export regression results for other intermediate outcomes in fu2
esttab _all	using "$results_tab/fu2_mechanisms_oth.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(%5.2fc) se(%5.2fc) ///
	keep(t1 t2) label booktabs nomtitles nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mlabels("Participated \\ decision-making" "Own \\ decision-making" "Registered" "Networking", prefix(\makecell{) suffix(}))




*** Table OA9: Big Five Personality Traits (12-month follow-up) ***

* Compute regression results for Big 5 personality traits in fu2
eststo clear
foreach var in neuroticism_index extraversion_index opennness_index agreeableness_index conscientiousness_index {
	_eststo `var': reg fu2_`var' t1 t2 $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Add corrections for multiple hypothesis testing
tempname pval_mat
if int(c(version))>=15 {
	mhtexp fu2_neuroticism_index fu2_extraversion_index fu2_opennness_index fu2_agreeableness_index fu2_conscientiousness_index, treatment(treatment)
	forvalues i=1/5 {
		local est: word `i' of neuroticism_index extraversion_index opennness_index agreeableness_index conscientiousness_index
		local t1_pos=`i'*2-1
		local t2_pos=`i'*2
		mat `pval_mat'=J(1,2,.)
		mat colnames `pval_mat' = t1 t2
		mat `pval_mat'[1,1]=results[`t1_pos',7]
		mat `pval_mat'[1,2]=results[`t2_pos',7]
		estadd mat mht=`pval_mat': `est'
	}
}
cap mat drop `pval_mat'

* Export regression results for Big 5 personality traits in fu2
esttab _all using "$results_tab/fu2_personality_big5.tex", replace star(* 0.10 ** 0.05 *** 0.01) cells(b(fmt(2) star) se(par) mht(fmt(3) par([ ]))) ///
	keep(t1 t2) label booktabs nomtitles collabels(none) nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mlabels("Neuroticism" "Extraversion" "Opennness" "Agreeableness" "Conscientiousness") ///
	substitute("-0.00" "0.00" "_" "\_" "$" "\$")




*** Table OA10: Task choice in Game 2 ***

* Compute regression results for the assisted/unassisted choice in Game 2
eststo clear
foreach var in g2_difficult_before g2_difficult_after {
	_eststo `var': reg fu2_`var' t1 t2 $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Export regression results for the easy/difficult choice in Game 2
esttab _all using "$results_tab/fu2_game2.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2) label booktabs nomtitles nonumbers nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mgroups("Chose NOT to get assistance", span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span}) begin("&(1)&(2)\\")) ///
	mlabels("Before seeing figure" "After seeing figure")




*** Table OA11: Goal Setting (12-month follow-up) ***

* Compute regression results for goals in fu2
eststo clear
foreach var in set_goal goal_quality {
	if regexm("`var'","set_goal") local base_controls m_set_goal d_set_goal
	else local base_controls ""
	_eststo b_`var': reg fu2_`var' t1 t2 `base_controls' $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0
	estadd scalar control_mean=r(mean)
}

* Add corrections for multiple hypothesis testing 
tempname pval_mat
if int(c(version))>=15 {
	mhtexp fu2_set_goal fu2_goal_quality, treatment(treatment)
	forvalues i=1/2 {
		local est: word `i' of set_goal goal_quality
		local t1_pos=`i'*2-1
		local t2_pos=`i'*2
		mat `pval_mat'=J(1,2,.)
		mat colnames `pval_mat' = t1 t2
		mat `pval_mat'[1,1]=results[`t1_pos',7]
		mat `pval_mat'[1,2]=results[`t2_pos',7]
		estadd mat mht=`pval_mat' : b_`est'
	}
}
cap mat drop `pval_mat'

* Export regression results for goals in fu2
esttab _all	using "$results_tab/fu2_goals.tex", replace star(* 0.10 ** 0.05 *** 0.01) cells(b(fmt(2) star) se(par) mht(fmt(3) par([ ]))) ///
	keep(t1 t2) label booktabs nomtitles collabels(none) nonotes nogaps ///
	stats(control_mean test_equality N, labels("Mean control group" "P-value equal t.e." "Observations") fmt(2 3 %9.0fc)) ///
	mlabels("Set goal" "Goal quality")




*** Table OA12: Heterogeneity of impact on main outcomes by gender (12-month follow-up) ***

* Generate interaction term
preserve
foreach var in t1 t2 {
	gen `var'_female=`var'*female
	lab var `var'_female "`: var lab `var'' $\times$ female"
}

* Compute regression results for heterogeneity by gender in fu2
eststo clear
foreach var in has_business sales_profits_index {
	_eststo `var': reg fu2_`var' t1 t2 female t1_female t2_female m_`var' d_`var' $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0 & female==1
	estadd scalar female_mean=r(mean)
	summ fu2_`var' if treatment==0 & female==0
	estadd scalar male_mean=r(mean)
}

* Export regression results for heterogeneity by gender in fu2
esttab _all using "$results_tab/fu2_main_outcomes_het_female.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1* t2*) label booktabs nonotes nogaps ///
	stats(female_mean male_mean test_equality N, labels("Mean control women" "Mean control men" "P-value equal t.e. for men" "Observations") fmt(2 2 3 %9.0fc)) ///
	mlabels("Firm survival" "Sales and profits index")
restore




*** Table OA13: Heterogeneity of potential mechanisms by gender (3-month follow-up) ***

* Generate interaction term
preserve
foreach var in t1 t2 {
	gen `var'_female=`var'*female
	lab var `var'_female "`: var lab `var'' $\times$ female"
}

* Compute regression results for heterogeneity by gender in fu1
eststo clear
foreach var in business_practices_index personal_initiative_index inputs_index innovation loan_requested {
	_eststo b_`var': reg fu1_`var' t1 t2 female t1_female t2_female m_`var' d_`var' $controls_md i.strata i.fu1_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu1_`var' if treatment==0 & female==1
	estadd scalar female_mean=r(mean)
	summ fu1_`var' if treatment==0 & female==0
	estadd scalar male_mean=r(mean)
}

* Export regression results for heterogeneity by gender in fu1
esttab _all using "$results_tab/fu1_mechanisms_het_female.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1* t2*) label booktabs nomtitles nonotes nogaps ///
	stats(female_mean male_mean test_equality N, labels("Mean control women" "Mean control men" "P-value equal t.e. for men" "Observations") fmt(2 2 3 %9.0fc)) ///
	mlabels("Business \\ practices" "Personal \\ initiative" "Capital and \\ labor inputs" "Introduced \\ innovation" "Loan \\ requested", prefix(\makecell{) suffix(}))
restore




*** Table OA14: Heterogeneity of potential mechanisms by gender (12-month follow-up) ***

* Generate interaction term
preserve
foreach var in t1 t2 {
	gen `var'_female=`var'*female
	lab var `var'_female "`: var lab `var'' $\times$ female"
}

* Compute regression results for heterogeneity by gender in fu2
eststo clear
foreach var in business_practices_index personal_initiative_index inputs_index innovation loan_requested {
	_eststo b_`var': reg fu2_`var' t1 t2 female t1_female t2_female m_`var' d_`var' $controls_md i.strata i.fu2_month_interview, robust
	test t1=t2
	estadd scalar test_equality=r(p)
	summ fu2_`var' if treatment==0 & female==1
	estadd scalar female_mean=r(mean) : b_`var'
	summ fu2_`var' if treatment==0 & female==0
	estadd scalar male_mean=r(mean) : b_`var'
}

* Export regression results for heterogeneity by gender in fu2
esttab _all using "$results_tab/fu2_mechanisms_het_female.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1* t2*) label booktabs nomtitles nonotes nogaps ///
	stats(female_mean male_mean test_equality N, labels("Mean control women" "Mean control men" "P-value equal t.e. for men" "Observations") fmt(2 2 3 %9.0fc)) ///
	mlabels("Business \\ practices" "Personal \\ initiative" "Capital and \\ labor inputs" "Introduced \\ innovation" "Loan \\ requested", prefix(\makecell{) suffix(}))
restore




*** Table OA15: Mediation analysis for men (3-month follow-up) ***

* Compute mediation results for men in fu1
preserve
set obs 20000
set seed 20180913
eststo clear
foreach var in business_practices_index personal_initiative_index inputs_index innovation loan_requested {
	* Compute results as normal regression
	_eststo `var': reg fu1_sales_profits_index t1 t2 fu1_`var' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview if female==0, robust
	summ fu1_`var' if treatment==0 & female==0
	estadd scalar control_mean=r(mean)
	* Compute CI separately by treatment arm
	forvalues i=1/2 {
		* Compute results for two channels with sureg
		sureg (a`i': fu1_`var' t`i' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview) ///
			(b`i': fu1_sales_profits_index fu1_`var' t`i' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview) if female==0
		* Generate random normal distributions and their product
		tempvar a`i' b`i' prod`i'
		gen `a`i'' =rnormal(_b[a`i':t`i'],_se[a`i':t`i'])
		gen `b`i'' =rnormal(_b[b`i':fu1_`var'],_se[b`i':fu1_`var'])
		gen `prod`i''=`a`i''*`b`i''
		* Store confidence intervals
		centile `prod`i'', cent(2.5 97.5)
		estadd scalar t`i'_ci_l=r(c_1) : `var'
		estadd scalar t`i'_ci_u=r(c_2) : `var'
		* Drop random variables
		drop `a`i'' `b`i'' `prod`i''
	}
}

* Export mediation results for men in fu1
esttab _all	using "$results_tab/fu1_mediation_men.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2 fu1_business_practices_index fu1_personal_initiative_index fu1_inputs_index fu1_innovation fu1_loan_requested) ///
	label booktabs nonumbers nonotes nogaps ///
	varlabels(fu1_business_practices_index "Business practices" fu1_personal_initiative_index "Personal initiative" fu1_inputs_index "Capital and labor inputs" ///
		fu1_innovation "Introduced innovation" fu1_loan_requested "Loan requested" fu1_loan_approved "Loan approved") ///
	stats(control_mean t1_ci_l t1_ci_u t2_ci_l t2_ci_u N, labels("Mean MV control group" "Monte Carlo 95\% C.I. for T1" "Monte Carlo 95\% C.I. for T2" "Observations") ///
		fmt(2 3 3 3 3 %9.0fc) layout(@ "[@,@]" "[@,@]" @)) ///
	mgroups("Effect on sales and profits index", span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span}) begin("&(1)&(2)&(3)&(4)&(5)\\")) ///
	mlabels("MV: Business \\ practices" "MV: Personal \\ initiative" "MV: Capital and \\ labor inputs" "MV: Introduced \\ innovation" "MV: Loan \\ requested", prefix(\makecell{) suffix(}))
restore




*** Table OA16: Mediation analysis for women (3-month follow-up) ***

* Compute mediation results for women in fu1
preserve
set obs 20000
set seed 20180913
eststo clear
foreach var in business_practices_index personal_initiative_index inputs_index innovation loan_requested {
	* Compute results as normal regression
	_eststo `var': reg fu1_sales_profits_index t1 t2 fu1_`var' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview if female==1, robust
	summ fu1_`var' if treatment==0 & female==1
	estadd scalar control_mean=r(mean)
	* Compute CI separately by treatment arm
	forvalues i=1/2 {
		* Compute results for two channels with sureg
		sureg (a`i': fu1_`var' t`i' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview) ///
			(b`i': fu1_sales_profits_index fu1_`var' t`i' m_sales_profits_index d_sales_profits_index $controls_md i.strata i.fu1_month_interview) if female==1
		* Generate random normal distributions and their product
		tempvar a`i' b`i' prod`i'
		gen `a`i'' =rnormal(_b[a`i':t`i'],_se[a`i':t`i'])
		gen `b`i'' =rnormal(_b[b`i':fu1_`var'],_se[b`i':fu1_`var'])
		gen `prod`i''=`a`i''*`b`i''
		* Store confidence intervals
		centile `prod`i'', cent(2.5 97.5)
		estadd scalar t`i'_ci_l=r(c_1) : `var'
		estadd scalar t`i'_ci_u=r(c_2) : `var'
		* Drop random variables
		drop `a`i'' `b`i'' `prod`i''
	}
}

* Export mediation results for women in fu1
esttab _all	using "$results_tab/fu1_mediation_women.tex", replace star(* 0.10 ** 0.05 *** 0.01) b(2) se(2) ///
	keep(t1 t2 fu1_business_practices_index fu1_personal_initiative_index fu1_inputs_index fu1_innovation fu1_loan_requested) ///
	label booktabs nonumbers nonotes nogaps ///
	varlabels(fu1_business_practices_index "Business practices" fu1_personal_initiative_index "Personal initiative" fu1_inputs_index "Capital and labor inputs" ///
		fu1_innovation "Introduced innovation" fu1_loan_requested "Loan requested" fu1_loan_approved "Loan approved") ///
	stats(control_mean t1_ci_l t1_ci_u t2_ci_l t2_ci_u N, labels("Mean MV control group" "Monte Carlo 95\% C.I. for T1" "Monte Carlo 95\% C.I. for T2" "Observations") ///
		fmt(2 3 3 3 3 %9.0fc) layout(@ "[@,@]" "[@,@]" @)) ///
	mgroups("Effect on sales and profits index", span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span}) begin("&(1)&(2)&(3)&(4)&(5)\\")) ///
	mlabels("MV: Business \\ practices" "MV: Personal \\ initiative" "MV: Capital and \\ labor inputs" "MV: Introduced \\ innovation" "MV: Loan \\ requested", prefix(\makecell{) suffix(}))
restore




*** Table OA17: Differences in Characteristics by gender ***

* Format variables for the table
format $all_covariates %9.2fc
format reservation_wage expenditures sales_lastm profits_lastm %9.0fc

* Build Panel A (Stratification variables)
balancetable female has_employees edu_sec_more course_kingston course_clarendon course_stthomas using "$results_tab/balance_gender.tex", replace ///
	vce(robust) pvalues pval(fmt(%5.2f)) displayformat nopar nostars varlabels booktabs ///
	groups("Men (M)" "Women (W)" "W=M", pattern(1 0 1 0 1) end("\cmidrule(lr){2-3}" "\cmidrule(lr){4-5}" "\cmidrule(lr){6-6}")) ///
	ctitles("Mean" "SD" "Mean" "SD" "P-val.") leftctitle(none) ///
	wide(mean sd pval) posthead("\midrule" "\multicolumn{6}{l}{\textbf{Panel A. Stratification variables}}\\") nofoot

* Build Panel B (Owner characteristics)
balancetable female age black married num_children internet_access parents_entrep save_bank loan_bank loan_notaccess set_goal business_wchange satisfied_job ///
	reservation_wage personal_initiative perseverance locus_control risk_willing expenditures pre_course using "$results_tab/balance_gender.tex", append ///
	vce(robust) pvalues pval(fmt(%5.2f)) displayformat nopar nostars varlabels booktabs ///
	wide(mean sd pval) nohead prehead("\addlinespace" "\multicolumn{6}{l}{\textbf{Panel B. Owner characteristics}}\\") nofoot

* Build Panel C (Firm characteristics)
balancetable female active_business busage_l1 formal_accounts informal_accounts register_bus sales_lastm profits_lastm ///
	innovation business_practices_index barriers_couple using "$results_tab/balance_gender.tex", append ///
	vce(robust) pvalues pval(fmt(%5.2f)) displayformat nopar nostars varlabels booktabs ///
	wide(mean sd pval) nohead prehead("\addlinespace" "\multicolumn{6}{l}{\textbf{Panel C. Firm characteristics}}\\")


